Deserialize a Dictionary

116

Deserialize a Dictionary -

string json = @"{
  'href': '/account/login.aspx',
  'target': '_blank'
}";

Dictionary<string, string> htmlAttributes = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);

Console.WriteLine(htmlAttributes["href"]);
// /account/login.aspx

Console.WriteLine(htmlAttributes["target"]);
// _blank

Comments

Submit
0 Comments